/**
 *
 */
package cn.fanyamin.dao.ibatis;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.fanyamin.dao.UserDao;
import cn.fanyamin.domain.EmailTask;
import cn.fanyamin.domain.User;


/**
 *
 * @author walter
 */
//public class SqlMapUserDao extends SqlMapClientDaoSupport implements UserDao {
public class SqlMapUserDao extends CRUDDao<Integer,User> implements UserDao {
    protected String domainName = "User";
    
    public SqlMapUserDao() {
        setSQLID(domainName);
    }

	public int fetchEmailTaskList(String executor, int count,  int maxDuration) {
	    Map<String, Object> map = new HashMap<String, Object>();
        
        map.put("executor", executor);
        map.put("count", count);
        map.put("duration",maxDuration);
	    return getSqlMapClientTemplate().update("fetchEmailTaskList", map);
	}
	
	public List<EmailTask> getEmailTaskList(String status,int count, String executor){
	    Map<String, Object> map = new HashMap<String, Object>();
                
        map.put("count", count);
        map.put("status", status);
        map.put("executor", executor);
        return (List<EmailTask>) getSqlMapClientTemplate().queryForList("getEmailTaskList", map);
	    
	}
	
    
    public int createEmailTask(EmailTask et) {
        return (Integer) getSqlMapClientTemplate().insert("createEmailTask", et);        
    }

    public EmailTask retrieveEmailTask(int etID) {
        return (EmailTask) getSqlMapClientTemplate().queryForObject("retrieveEmailTask", etID);        
    }
    
    public int deleteEmailTask(int etID) {
        return getSqlMapClientTemplate().delete("deleteEmailTask", etID);
    }

   
    public int updateEmailTask(cn.fanyamin.domain.EmailTask et) {
        return getSqlMapClientTemplate().update("updateEmailTask", et);
    }

	public User findUserByName(String userName) {
		User user = new User();
		user.setUserName(userName);
		return (User) getSqlMapClientTemplate().queryForObject("findUserByName", userName);
	}

   

	
}